# 导模块--创建文稿--添加幻灯片 6
from pptx import Presentation
from pptx.util import Inches

# 1.创建文稿
pre = Presentation()

slide_layout = pre.slide_layouts[6]
slide = pre.slides.add_slide(slide_layout)

# 2.添加  表格 table

# 定义表的位置
x, y, cx, cy = Inches(2), Inches(2), Inches(6), Inches(4.5)
# 插入表
shape = slide.shapes.add_table(
    4, 8, x, y, cx, cy
)

# 3.添加数据
table = shape.table

for i in range(4):
    for j in range(8):
        cell = table.cell(i, j)
        cell.text = '{}-{}'.format(i,j)

# 保存文稿
pre.save('table.pptx')

print('添加表格....')
